package org.wm.springcloud.controller;

import com.wm.entities.CommonResult;
import com.wm.entities.Payment;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RestController;
import org.wm.springcloud.service.PaymentFeginService;

import javax.annotation.Resource;

/**
 * @ClassName:OrderFeginController
 * @Description: 订单支付远程调用Controller
 * @Author:Deamer
 * @Date:2021/11/26 21:59
 **/
@RestController
@Slf4j
public class OrderFeginController {

    @Resource
    private PaymentFeginService paymentFeginService;

    /**
     * 支付订单
     *
     * @param id
     * @return
     */
    @GetMapping("/consumer/payment/get/{id}")
    public CommonResult<Payment> getPaymentById(@PathVariable("id") Long id) {
        return paymentFeginService.getPaymentById(id);
    }

    /**
     * 模拟超时
     *
     * @return
     */
    @GetMapping("/consumer/payment/fegin/timeout")
    public String paymentFeginTimeOut() {
        // OpenFeign客户端一般默认等待1s
        return paymentFeginService.paymentFeginTimeOut();
    }
}
